package com.roc.web.action.ysb;

import java.util.ArrayList;
import java.util.List;

import com.roc.page.BaseSearchCondition;
import com.roc.page.WhereHQLFieldBean;
import com.roc.util.Constance;

public class YsbCarryRewardQuerySearchCondition extends BaseSearchCondition{

	private String beginTime;
	private String agentFlag;
	private long loginid;
	protected String getOrderPartOfHQL() {
		return null;
	}

	@Override
	protected String getRowCountHQL() {
		
		StringBuffer sb = new StringBuffer();
		sb.append("   select count(1)   from (                       \n ");
		sb.append("   select t.companyid,                           \n ");
		sb.append("          t.real_name,                           \n ");
		sb.append("          t.certif_no,                           \n ");
		sb.append("          t.mcht_cd,                             \n ");
		sb.append("          t.serial_num,                          \n ");
		sb.append("          t.trans_amt,            \n ");
		sb.append("          t.stlm_date                            \n ");
		sb.append("     from apsmgm.tbl_ysb_carry_reward_info t     \n ");
		sb.append("    where 1 = 1     and t.trans_cd='D0'  and t.trans_amt>=20000                \n ");
		if(Constance.isNotEmpty(agentFlag)&&"1".equals(agentFlag)){
			sb.append("      and exists (select 1                       \n ");
			sb.append("             from apsmgm.t_operators o           \n ");
			sb.append("            where o.id = t.agent_id              \n ");
			sb.append("              and o.supri_id =").append(loginid).append("  )          \n ");
		}else{
		    sb.append("      and t.agent_id =").append(loginid).append("        \n ");
		}
		if(Constance.isNotEmpty(beginTime)){
		    sb.append("      and t.stlm_date ='").append(beginTime).append("' \n");
		}
		sb.append("               )                  \n ");

	    return sb.toString();

	}


	protected String getSearchHQL() {

		StringBuffer sb = new StringBuffer();
		sb.append("   select t.companyid,                           \n ");
		sb.append("          t.real_name,                           \n ");
		sb.append("          substr(t.certif_no,0,6)||'*******'|| substr(t.certif_no,length(t.certif_no)-3,4) certif_no,                           \n ");
		sb.append("          t.mcht_cd,                             \n ");
		sb.append("          t.serial_num,                          \n ");
		sb.append("          t.trans_amt,            \n ");
		sb.append("          t.stlm_date                            \n ");
		sb.append("     from apsmgm.tbl_ysb_carry_reward_info t     \n ");
		sb.append("    where 1 = 1    and t.trans_cd='D0'  and t.trans_amt>=20000                    \n ");
		if(Constance.isNotEmpty(agentFlag)&&"1".equals(agentFlag)){
			sb.append("      and exists (select 1                       \n ");
			sb.append("             from apsmgm.t_operators o           \n ");
			sb.append("            where o.id = t.agent_id              \n ");
			sb.append("              and o.supri_id =").append(loginid).append("  )          \n ");
		}else{
		    sb.append("      and t.agent_id =").append(loginid).append("        \n ");
		}
		if(Constance.isNotEmpty(beginTime)){
		    sb.append("      and t.stlm_date ='").append(beginTime).append("' \n");
		}
		return sb.toString();
	}
	@Override
	protected List<WhereHQLFieldBean> getWhereHQLFieldBeanList() {
		List<WhereHQLFieldBean> filedBeanList = new ArrayList<WhereHQLFieldBean>();

		return filedBeanList;
	}


	public String getBeginTime() {
		return beginTime;
	}


	public void setBeginTime(String beginTime) {
		this.beginTime = beginTime;
	}


	public String getAgentFlag() {
		return agentFlag;
	}



	public void setAgentFlag(String agentFlag) {
		this.agentFlag = agentFlag;
	}



	public long getLoginid() {
		return loginid;
	}



	public void setLoginid(long loginid) {
		this.loginid = loginid;
	}






}
